package userService

import (
	"news_for_deepseek_interface/model"
	adminModel "news_for_deepseek_interface/model/admin"

	"gorm.io/gorm"
)

func Delete(ids []int) error {
	db := model.GetInstance().GetDB()

	return db.Transaction(func(tx *gorm.DB) error {
		// 删除用户
		if err := tx.Where("id in ?", ids).
			Delete(&adminModel.AdminStruct{}).Error; err != nil {
			return err
		}

		// 删除用户token
		if err := tx.Where("admin_id in ?", ids).
			Delete(&adminModel.AdminTokenStruct{}).Error; err != nil {
			return err
		}

		return nil
	})
}
